package sanrenxing.dayEnd.backRepertoryTotal.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import sanrenxing.dayEnd.backRepertoryTotal.domain.DayStatement;

import java.util.List;

/**
 * 功能:
 * 编写者：
 * 日期：2021
 * 版本：1.0
 */
public interface DayStatementDao {
    /**
     * 根据证券代码删除一行
     *
     * @param seId
     * @return
     */
    @Delete("delete from dayStatement where seId=#{seId}")
    public int delete(@Param("seId") String seId);

    /**
     * 分页查询条件
     *
     * @param start
     * @param rows
     * @param condition
     * @return
     */
    @Select("select s.seId,s.seName,se.tranNum,se.tranMoney,(se.price*se.tranMoney*t.commRate) commRate,(se.price*se.tranMoney*e.handFee) handFee,(se.price*se.tranMoney*e.staDuty) staDuty,\n" +
            "(se.price*se.tranMoney*e.tranFee) tranFee,(se.price*se.tranMoney*e.collFee) collFee,se.settMoney as amos,se.tranDate from  securitiesTradingData se\n" +
            "join financialsecurities s on se.seId=s.seId join exchangeVarietyRate e on s.BreedRateId=e.BreedRateId join tradingSeat t on se.stockId=t.stockId where se.tranStatus=1")
    public List<DayStatement> findByPage(@Param("start") int start, @Param("rows") int rows, @Param("condition") String condition);

    /**
     * 按条件统计记录数
     *
     * @param condition 统计条件
     * @return 条件
     */
    @Select("select count(*) from securitiesTradingData se\n" +
            "join financialsecurities s on se.seId=s.seId join exchangeVarietyRate e on s.BreedRateId=e.BreedRateId join tradingSeat t on se.stockId=t.stockId where se.tranStatus=1 and 1=1 ${condition}")
    public int count(@Param("condition") String condition);
}
